{{define "base/base_list.html"}}
{{template "base/header" .}}
<div class="admin-table-full">
    <!--查询栏-->
    {{if .ModelPage.SearchPage}}
    {{template  "base/search_form" .}}
    {{end}}
    <!--工具栏-->
    <script type="text/html" id="main_table_toolbar">
        <div class="layui-btn-container">
            <!--
            {{range $key, $button := .Result.menu_buttons}}
                {{template "base/one_button" $button}}
            {{end}}
            -->
            <a class="layui-btn layui-btn-sm" id="openLink_add" lay-event="openLink_add" admin-href="/system/menu/add" open-type="4">添加</a>
            <a class="layui-btn layui-btn-sm" id="openLink_edit" lay-event="openLink_edit" admin-href="/system/menu/edit" open-type="4" param-type="2" default="true"->编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-sm" id="openLink_del" lay-event="openLink_del" admin-href="/system/menu/del" open-type="5" param-type="3" confirm="你确定要删除吗？">删除</a>

        </div>
    </script>

    <table class="layui-hide" id="main_table"></table>
</div>
<script type="text/javascript">
    var cols = [[
        {"type": {{if .ModelPage.List.Single}}"radio"{{else}}"checkbox"{{end}}, "fixed": "left"},
        {{if .ModelPage.List.Number}}
        {"field": "__mc_index", "title":"序号", "fixed":"left", "width": 80, "sort": false},
        {{end}}
        {{range $i, $fieldName := .ModelPage.Items}}
        {{$field := index $.ModelPage.Fields $fieldName}}
        {
            "field":"{{$field.Name}}",
            "title": "{{$field.Title}}",
            "align":"{{$field.Align}}",
            "width":"{{$field.Width}}",
            "sort":{{$field.Sort}},
            "fixed": "{{$field.Fixed}}"
            {{if $.ModelPage.List.IsCount}}{{if eq $field.Name $.Model.Table.Pk}},"totalRowText":"{{$.ModelPage.List.CountText}}"{{end}}{{end}}
        },
        {{end}}
    ]];


    pageCallBack = function(){
        layui.use(['jquery','admin','fulltable'],function(){
            var $ = layui.jquery,
                admin = layui.admin,
                fulltable = layui.fulltable;

            admin.global.tableId = "main_table"; //必须单独使用 tableId 变量单独定义，表示表格的id,用于操作自动获取参数来源
            admin.global.pkField = "{{.Model.Table.Pk}}"; //必须单独使用 pkField 变量单独定义，表示主键字段名,用于操作自动获取参数来源
            //重新定义行双击事件回调方法
            fulltable.onRowDouble = function(obj){
                fulltable.onlyOneSelected(obj);
                $('.layui-table-tool-temp [default]').eq(0).click();
            };
            fulltable.render({
                id: admin.global.tableId,
                elem:"#main_table",
                totalRow: {{.ModelPage.List.IsCount}},
                cols: cols
            }); //表格数据选项（参考layui.table文档）

        });
    };
</script>
{{template "base/footer" .}}
{{end}}